<template>
	<view>
		<!-- 顶部标题的背景色 -->
		<view class="nav_bar_container" :style="{height: navBarHeight+'px'}">
			<image class="_img" src="https://img2.baidu.com/it/u=4134404395,864195599&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=666" mode="aspectFill"></image>
			<view class="_content">
				<view class="_title">跟着城市疯狂的运动起来，一起来看成都运动</view>
				<view class="_count">
					<view class="_cell">
						<text class="_n">84545</text>
						<text>人参与</text>
					</view>
					<view class="_cell">
						<text class="_n">84545</text>
						<text>人阅读</text>
					</view>
				</view>
			</view>
		</view>
		
		<uni-list-view
			:height="scrollHeight"
			url="labor/labor/mian/findPage"
			requestMethod="GET"
			@loadData="loadData"
		>
			<view class="news_wrap">
				<view class="news_item" v-for="(item, index) in newsList" :key="index" @click="routeDetail(item)">
					<image class="_img" v-for="(img, i) in 5" :key="i" mode="aspectFill" src="https://img2.baidu.com/it/u=4134404395,864195599&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=666"></image>
					<view class="_content">
						<view class="_p1">
							<text class="_name">赵四</text>
							<text class="_level">初级</text>
						</view>
						<view class="_p2">
							<view class="_popular">
								<i class="iconfont icon-renqi"></i>
								<text>350</text>
							</view>
							
							<view class="_works">
								<i class="iconfont icon-zuopin"></i>
								<text>152</text>
							</view>
						</view>
					</view>
				</view>
			</view>
			
		</uni-list-view>
		
	</view>
</template>

<script>
	import UniListView from "@/components/uni-list-view/index.vue" 
	export default {
		data() {
			return {
				navBarHeight: 0, // 导航栏的高度
				scrollHeight: 0,
				newsList: [],
			}
		},
		components: {
			UniListView
		},
		onLoad() {
			this.getNavBarHeight();
		},
		methods: {
			// 计算滚动条的高度
			async getNavBarHeight() {
				let sysInfo =  await uni.getSystemInfoAsync()
				// 顶部大图的高度
				this.navBarHeight = sysInfo.statusBarHeight + 44 + 160;
				// 滚动条高度
				this.scrollHeight = sysInfo.windowHeight - this.navBarHeight
			},
			
			// 加载新闻资讯数据
			loadData(list) {
				this.newsList = list
			},
			
			// 跳转详情
			routeDetail(item) {
				console.log(item);
				uni.navigateTo({
					url: "/pages/interview/detail"
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.nav_bar_container{
		position: relative;
		._img{
			width: 100%;
			height: calc(100% - 50px);
			display: block;
			border-radius: 0 0 30rpx 30rpx;
		}
		._content{
			position: absolute;
			z-index: 3;
			left: 30rpx;
			right: 30rpx;
			bottom: 0;
			height: 90px;
			background: linear-gradient(to bottom, #e083a2, #ffffff);
			border-radius: 30rpx 30rpx 0 0;
			padding: 30rpx;
			box-sizing: border-box;
			._title{
				font-weight: bold;
				font-size: 36rpx;
				color: #333;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
				margin-bottom: 15rpx;
			}
			._count{
				display: flex;
			}
			._cell{
				flex: 1;
				color: #888;
				display: flex;
				align-items: center;
				._n{
					font-weight: bold;
					font-size: 42rpx;
					color: #000;
				}
			}
		}
	}
	
	.news_wrap{
		padding: 30rpx 0 0 30rpx;
		display: flex;
		flex-wrap: wrap;
		background-color: #fff;
	}
	.news_item{
		border-bottom: 1px solid #eee;
		background: #fff;
		width: 330rpx;
		height: 400rpx;
		margin-right: 30rpx;
		margin-bottom: 30rpx;
		position: relative;
		border-radius: 15rpx;
		overflow: hidden;
		._img{
			position: absolute;
			top: 0;
			left: 0;
			width: inherit;
			height: inherit;
		}
		._content{
			position: absolute;
			z-index: 3;
			left: 20rpx;
			bottom: 20rpx;
			right: 20rpx;
			background: rgba(0,0,0,0.3);
			backdrop-filter: blur(8px);
			border-radius: 15rpx;
			padding: 20rpx 20rpx 20rpx 20rpx;
			color: #fff;
			._p1{
				display: flex;
				margin-bottom: 15rpx;
				._level{
					margin-left: 40rpx;
				}
			}
			._p2{
				display: flex;
				justify-content: space-between;
				._popular{
					display: flex;
					align-items: center;
				}
				._works{
					display: flex;
					align-items: center;
				}
			}
		}
	}
</style>
